// run: $exec < input
#include <iostream>

int const maxn = 303;
char a[maxn][maxn];
int n;

int main()
{
	std::cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) std::cin >> a[i][j];
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (a[i][i] != a[0][0]) {
			ok = false;
			break;
		}
		if (a[i][n - i - 1] != a[0][0]) {
			ok = false;
			break;
		}
	}
	if (a[0][0] == a[0][1]) ok = false;
	if (!ok) { std::cout << "NO\n"; return 0; }
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j || i == n - j - 1) continue;
			if (a[i][j] != a[0][1]) { ok = false; break; }
		}
		if (!ok) break;
	}
	if (!ok) std::cout << "NO\n";
	else std::cout << "YES\n";
}


